import Vue from 'vue'
import Router from 'vue-router'
import index from '../components/index'
import demo from '../components/demo'
import nav from '../components/nav'

import Login from '../views/Login'
import gongcheng from '../views/gongcheng/gongcheng'
import xiezilou from '../views/gongcheng/xiezilou'
import zhuzhai from '../views/gongcheng/zhuzhai'
import dianfei from '../views/gongcheng/dianfei'
import shangchang from '../views/gongcheng/shangchang'
import diantu from '../views/gongcheng/diantu'
import shuitu from '../views/gongcheng/shuitu'
import shebei from '../views/gongcheng/shebei'
import yinhang from '../views/gongcheng/yinhang'
import jiaban from '../views/gongcheng/jiaban'
import VueAxios from 'vue-axios'
// eslint-disable-next-line no-unused-vars
import time from '../components/time'

var axios = require('axios')
axios.defaults.baseURL = 'http://localhost:8001'
// 全局注册，之后可在其他组件中通过 this.$axios 发送数据
Vue.prototype.$axios = axios

Vue.use(Router)
Vue.use(VueAxios, axios)

// 解决同一个路由被多次添加
const VueRouterPush = Router.prototype.push
Router.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
export default new Router({
  routes: [
    {
      path: '/nav',
      name: 'nav',
      component: nav,
      redirect: '/index',
      children: [{
        path: '/index',
        name: 'index',
        component: index
      }, {
        path: '/gongcheng',
        component: gongcheng
      }, {
        path: '/demo',
        name: 'demo',
        component: demo
      }, {
        path: '/xiezilou',
        component: xiezilou
      }, {
        path: '/zhuzhai',
        component: zhuzhai
      }, {
        path: '/dianfei',
        component: dianfei
      }, {
        path: '/shangchang',
        component: shangchang
      },
      {path: '/diantu', component: diantu}, {
        path: '/shuitu',
        component: shuitu
      }, {
        path: '/shebei',
        component: shebei
      }, {
        path: '/jiaban',
        component: jiaban
      }, {
        path: '/yinhang',
        component: yinhang
      }
      ]
    }, {
      path: '/time',
      name: 'time',
      component: time
    }, {
      path: '/',
      name: 'Login',
      component: Login
    },

  ]
})
